package vue;



import java.awt.BorderLayout;
import java.awt.Dimension;


import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import controleur.ControleLoadFile;
import controleur.ControleSaveFile;

import modele.CKModel;


public class VueEditeurCK {
	
	private CKModel<String, String> _modele;
	
	
	private JFrame editorFrame;
	private PanelCK pnlCK;
	private PanelC0 pnlC0;
	private PanelK0 pnlK0;
	private PanelPartition pnlPart;
	private PanelAddKnowledge pnlAddK;
	private PanelText pnlT;
	private PanelChoice pnlC;
	
	
	
	
	private JMenuBar barreMenu;
	private JMenu actionMenu;
	private JMenu help;
	private JMenuItem savePNGItem;
	private JMenuItem saveGraphItem;
	private JMenuItem loadGraphItem;
	private JMenuItem close;
	private JMenuItem createGraphCK;
	private JMenuItem actionHelp;
	
	
	
		public VueEditeurCK(CKModel<String, String> modele){
			
			this.setModel(modele);
		

			editorFrame = new JFrame();
			editorFrame.setTitle("Simple C-K Editor 1.0 (alpha) Ecole des Mines ParisTech");
			editorFrame.setSize(new Dimension(800, 1000));
			editorFrame.setLocation(300,100);
			editorFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Set to
																		// exit when
																		// we close
																		// the frame
			
			
			
			pnlC0 = new PanelC0(_modele, this);
			
			
			actionMenu = new JMenu("Actions");
			help = new JMenu("Aide");
	
			/*
			 * Save to file
			 */
			saveGraphItem = new JMenuItem("Enregistrer le graphe");
			saveGraphItem.addActionListener(new ControleSaveFile(_modele));
			actionMenu.add(saveGraphItem);
			
			/*
			 * Load a file
			 */
			loadGraphItem = new JMenuItem("Charger un graphe");
			loadGraphItem.addActionListener(new ControleLoadFile(_modele));
			actionMenu.add(loadGraphItem);
			
			actionMenu.addSeparator();
			
			/*
			 * Save to PNG Item
			 */
			savePNGItem = new JMenuItem("Exporter en image");
			actionMenu.add(savePNGItem);
			
			actionMenu.addSeparator();
			
			close = new JMenuItem("Quitter");
			actionMenu.add(close);
			
			
			/*
			 * Explication sur la création d'un arbre C-K
			 */
			createGraphCK = new JMenuItem("Comment créer un arbre C-K");
			help.add(createGraphCK);
			
			/*
			 * Explication sur les différente action du menu action
			 */
			actionHelp = new JMenuItem("Aide Actions");
			help.add(actionHelp);
			
			barreMenu = new JMenuBar();
			barreMenu.add(actionMenu);
			barreMenu.add(help);

			// Add the menu to the container
			editorFrame.setJMenuBar(barreMenu);
			editorFrame.add(pnlC0, BorderLayout.NORTH);
			
		
	}
	
			
	/**
	* @return the editorFrame
	*/
	public JFrame getEditorFrame(){
		return editorFrame;
	}
	
	
	/**
	* @return the width editorFrame 
	*/
	public int getFrameWidth(){
		return editorFrame.getWidth();
	}
	
	
	/**
	* @return the height editorFrame 
	*/
	public int getFrameHeight(){
		return editorFrame.getHeight();
	}
	
	
	public void dessiner(){
		editorFrame.setVisible(true);
	}
	
	/**
	 * 
	 * @return the PanelCK
	 */
	public PanelCK getPanelCK(){
		return this.pnlCK;
	}
	
	public void setPanelCK(PanelCK pnl){
		this.pnlCK = pnl;
	}
	
	/**
	 * 
	 * @return the PanelInit
	 */
	public PanelC0 getPanelC0(){
		return this.pnlC0;
	}
	
	/**
	 * @param pnlK0 the pnlK0 to set
	 */
	public void setPanelK0(PanelK0 pnlK0) {
		this.pnlK0 = pnlK0;
	}


	/**
	 * @return the pnlK0
	 */
	public PanelK0 getPanelK0() {
		return pnlK0;
	}


	/**
	 * @param pnlC the pnlC to set
	 */
	public void setPanelC(PanelChoice pnlC) {
		this.pnlC = pnlC;
	}


	/**
	 * @return the pnlC
	 */
	public PanelChoice getPanelC() {
		return pnlC;
	}


	/**
	 * @param pnlPart the pnlPart to set
	 */
	public void setPanelPart(PanelPartition pnlPart) {
		this.pnlPart = pnlPart;
	}


	/**
	 * @return the pnlPart
	 */
	public PanelPartition getPanelPart() {
		return pnlPart;
	}


	/**
	 * @param pnlAddK the pnlAddK to set
	 */
	public void setPanelAddK(PanelAddKnowledge pnlAddK) {
		this.pnlAddK = pnlAddK;
	}


	/**
	 * @return the pnlAddK
	 */
	public PanelAddKnowledge getPanelAddK() {
		return pnlAddK;
	}


	public void setModel(CKModel<String, String> modele){
		this._modele = modele;
	}


	/**
	 * @param pnlT the pnlT to set
	 */
	public void setPanelT(PanelText pnlT) {
		this.pnlT = pnlT;
	}


	/**
	 * @return the pnlT
	 */
	public PanelText getPanelT() {
		return pnlT;
	}

}
